package april.fastjson.date_format;

import java.util.Date;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.JSONSerializer;
import com.alibaba.fastjson.serializer.SerializeWriter;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class UseISO8601DateFormat {

	public static void main(String[] args) {

		SerializeWriter out = new SerializeWriter();
		JSONSerializer serializer = new JSONSerializer(out);

		serializer.config(SerializerFeature.UseISO8601DateFormat, true);

		serializer.write(new Date(1294552193254L));

		String text = out.toString();

		System.out.println(text);

		Date date = (java.util.Date) JSON.parseObject(
				"\"2011-01-09T13:49:53\"", Date.class,
				Feature.AllowISO8601DateFormat);
		System.out.println(date.toString());
	}

}
